package com.controller;

import java.util.List;

import com.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.entity.Ground;
import com.mapper.GroundMapper;
import com.service.GroundService;

@SuppressWarnings({"all"})
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/ground")
public class GroundController {
    @Autowired
    private GroundService groundService;

    @GetMapping("/list")
    public Result getGroundList() {
        try{
            return Result.success(groundService.getAllGround());
        }catch (Exception e){
            return Result.error(e.getMessage());
        }
    }

    @PostMapping("/insert")
    public Result insertGround(Ground ground) {
        System.out.println("进入控制器insertGround："+ground);
        try {
            return Result.success(groundService.insertGround(ground));
        }catch (Exception e){
            return Result.error(e.getMessage());
        }
    }

    @DeleteMapping("/del")
    public Result delectGround(Ground ground) {
        try {
            return Result.success(groundService.deleteGround(ground));
        }catch (Exception e){
            return Result.error(e.getMessage());
        }
    }

    @PostMapping("/update")
    public Result updateGround(Ground ground)
    {
        System.out.println("updateGround的updateGround:"+ground);
        try {
            return Result.success(groundService.updateGround(ground));
        }catch (Exception e){
            return Result.error(e.getMessage());
        }
    }
}
